#include <benchmark/benchmark.h>
#include <sys/ioctl.h>
#include <stdio.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include "util.h"

#define DEVICE_FILE "/data/test.txt"
static void Bm_function_Ioctl(benchmark::State &state)
{
    char buf[1024];
    int fd = open(DEVICE_FILE, O_RDONLY | O_CREAT);
    if (fd == -1)
    {
        perror("open ioctl");
        exit(EXIT_FAILURE);
    }
    for (auto _ : state)
    {
        ioctl(fd, -1070571007, buf);
    }

    state.SetBytesProcessed(state.iterations());
}

MUSL_BENCHMARK(Bm_function_Ioctl);